package com.zhuiyun.project.api.groupmessage.controller;

import com.zhuiyun.project.api.groupmessage.service.GroupMessageService;
import com.zhuiyun.project.common.response.CommonResult;
import com.zhuiyun.project.util.pageUtil.PageRequest;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName GroupMessageController
 * @Description TODO
 * @Author kdj
 * @Date 2023/7/24 19:44
 **/
@RestController
@CrossOrigin
@RequestMapping("/groupMessage")
public class GroupMessageController {
    @Autowired
    private GroupMessageService groupMessageService;


    /**
     * @param userId
     * @param groupId
     * @param type
     * @Author kdj
     * @Description 根据群聊 群聊id 用户类型获取群聊列表消息
     * @Date 2023/7/25 10:29
     * @Return com.zhuiyun.project.common.response.CommonResult
     */
    @GetMapping("/getGroupChat")
    public CommonResult getGroupChat(int userId, int groupId, int type,PageRequest pageRequest) {
        return CommonResult.ok(groupMessageService.getGroupChat(userId, groupId, type,pageRequest)) ;
    }
    /**
     * @param userId
     * @param groupId
     * @param type
     * @Author kdj
     * @Description 根据群聊 群聊id 用户类型获取群聊列表消息  系统
     * @Date 2023/7/25 10:29
     * @Return com.zhuiyun.project.common.response.CommonResult
     */
    @GetMapping("/getGroupChatSys")
    public CommonResult getGroupChatSys(int userId, int groupId, int type, PageRequest pageRequest,String time) {
        return CommonResult.ok(groupMessageService.getGroupChatSys(userId, groupId, type,pageRequest,time)) ;
    }

    /**
    * @Author kdj
    * @Description 清楚未读数
    * @Date 2023/7/29 20:36
    * @Return com.zhuiyun.project.common.response.CommonResult
    * @param groupId
 * @param userId
    */
    @GetMapping("/cleanUnReadMsg")
    public CommonResult cleanUnReadMsg(int groupId, int userId ) {
        return CommonResult.ok(groupMessageService.cleanUnReadMsg(groupId, userId )) ;
    }
}
